<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"  lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <title>登录</title>
</head>
<body>
<h4 id="erro"></h4>
<form>
    <p>
        账号：<input type="text" name="username" id="username" value="chenw" />
    </p>
    <p>
        密码：<input type="text" name="password" id="password" value="123456" />
    </p>
    <p>
        <input type="button" id="ajaxLogin" value="登录" />
    </p>
</form>
<script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
<script>
    $("#ajaxLogin").click(function() {
        var username = $("#username").val();
        var password = $("#password").val();
        $.post("/ajaxLogin", {
            "username" : username,
            "password" : password
        }, function(result) {
            if (result.status == 200) {
                location.href = "/user";
            } else {
                $("#erro").html(result.message);
            }
        });
    });
</script>
</body>

</html>